//
//  RdbColor.swift
//  rdb-led-banner
//
//  Created by GJC on 2025/4/21.
//

import Foundation
import UIKit

class RdbColor: NSObject{
    
    static let shared = RdbColor()
    
    private(set) var theme: RdbColor.theme = .green
    
    override init() {
        super.init()
        if let colorStr = RdbUserDefaults.stringValue(for: .rdbThemeColor){
            self.theme = RdbColor.theme(colorStr)
        }
    }
    
    func updateTheme(_ theme: RdbColor.theme){
        self.theme = theme
    }
    
}

extension RdbColor{
    
    public struct theme{
        public var rawValue: String
        public var color: UIColor {
            get{
                return UIColor(self.rawValue)
            }
        }
        public init(_ rawValue: String) {
            self.rawValue = rawValue
        }
    }
    
    public struct background{
        public var rawValue: String
        
        public var color: UIColor {
            get {
                return UIColor(self.rawValue)
            }
        }

        public init(_ rawValue: String) {
            self.rawValue = rawValue
        }
    }
}


extension RdbColor.theme {
    static let purple = RdbColor.theme("#FF00E3")
    static let yellow = RdbColor.theme("#FFF741")
    static let green = RdbColor.theme("#45FF63")
    static let orange = RdbColor.theme("#FF6231")
    static let pink = RdbColor.theme("#FF7ADA")
    static let blue = RdbColor.theme("#45B1FF")
}

extension RdbColor.background {
    static let main = RdbColor.theme("#222222")
    static let content = RdbColor.theme("#333333")
}
